package map06;

import java.util.HashMap;
import java.util.LinkedHashMap;

/**
 * LinkedHashMap使用
 *   1.LinkedHashMap保证存储的Key唯一(唯一原理还是依赖hashCode()方法和equals()方法)
 *   2.LinkedHashMap可以保证key的存取顺序一致
 */
public class LinkedHashMapDemo01 {
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<>();
        hm.put(42, "abc");
        hm.put(42, "def");
        hm.put(52, "mn");
        hm.put(1, "ghk");
        System.out.println(hm);


        LinkedHashMap<Integer, String> lhm = new LinkedHashMap<>();
        lhm.put(42, "abc");
        lhm.put(42, "def");
        lhm.put(52, "mn");
        lhm.put(1, "ghk");
        System.out.println(lhm);
    }
}
